﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Hotnet.Entity;
using Ninject.Core;
using Hotnet.Dal.NSDalNews;

namespace Hotnet.Biz.NSBizNews
{
	public class BizNewsCategory:BaseBiz<NewsCategory>
	{
		private static DalNewsCategory dalNewsCategory = new DalNewsCategory();

		private BizNews _BizNews;
		private BizNews BizNews
		{
			get
			{
				if (_BizNews == null)
					_BizNews = new BizNews();
				return _BizNews;
			}
		}


		public BizNewsCategory() : base(dalNewsCategory) { }

		/// <summary>
		/// 删除新闻分类,级联删除新闻
		/// </summary>
		/// <param name="categoryId"></param>
		public override void Delete(int categoryId)
		{
			//开始事务
			//using (DbTransaction tran = dalPictureCategory.BeginTransaction())
			//{
			//删除所有新闻
			BizNews.DeleteAllByCategoryId(categoryId);
			//删除新闻分类
			base.Delete(categoryId);
			//    if (true)
			//        throw new Exception("我是故意的!");
			//    tran.Commit();
			//}
		}
	}
}
